class DynamicFunctionCreator:
    def __init__(self, func_name, param_names):
        def generated_function(self, **kwargs):
            result = []
            for param in param_names:
                value = kwargs.get(param)
                result.append(f"{param}: {value}")
            return ", ".join(result)

        setattr(self, func_name, generated_function.__get__(self, self.__class__))


if __name__ == "__main__":
    # 创建类的实例，传入函数名和参数名列表
    example = DynamicFunctionCreator("new_function", ["param1", "param2"])

    # 调用动态生成的函数
    output = example.new_function(param1="hello", param2="world")
    print(output)
    